package com.vint.leetcode;

import java.util.HashMap;
import java.util.Map;

/*
 * 1. done
 * 2. easy
 */
public class Leetcode1 {
	public int[] twoSum(int[] nums, int target) {
		int size = nums.length;
		if(size <= 1){
			return null;
		}
		Map<Integer, Integer> res = new HashMap<>();
		for(int i = 0; i < size; i++){
			if(res.keySet().contains(nums[i])) {
				return new int[]{i, res.get(nums[i])};
			} else{
				res.put(target - nums[i], i);
			}
		}
		return null;
	}
	public static void main(String[] args) {
		Leetcode1 leetcode1 = new Leetcode1();
		int[] nums = new int[]{3, 2, 4};
		leetcode1.twoSum(nums, 6);
	}
}
